<template>
  <div id="readingformdiv">
    <el-table :data="read" style="width: 100%">
      <el-table-column prop="报建编号" label="收文编号">
        <template slot-scope="scope">
          <a @click="showSingle(scope.row)">{{scope.row.报建编号}}</a>
        </template>
      </el-table-column>
      <el-table-column prop="传阅类型" :show-overflow-tooltip="true" label="传阅类型"></el-table-column>
      <el-table-column prop="项目名称" label="来文名称" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="建设单位" label="单位" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="接收时间" label="接收时间" :show-overflow-tooltip="true"></el-table-column>
    </el-table>
  </div>
</template>
<script type="text/javascript">
  import { ACCESS_TOKEN,ACCESS_TOKEN_IP } from '@/store/mutation-types'
  import Vue from 'vue'
  import { openIFrame } from '@/utils/util'

  export default {
    data() {
      return {
        timer:'',
        count: 0,
        read: []
      }
    },
    mounted() {
      this.getGeneralList()
      // 每5分钟刷新一次
      this.timer = setInterval(this.getGeneralList, 300000);
    },
    beforeDestroy() {
      clearInterval(this.timer);
    },
    methods: {
      //给父组件传值
      sendCountToParent() {
        this.$emit('getReadCount', this.count)
      },
      showSingle(record) {
        let baseUrl = process.env.VUE_APP_ADD_HTTP
        let ticket = Vue.ls.get(ACCESS_TOKEN)
        let UserIP = "&UserIP="+ Vue.ls.get(ACCESS_TOKEN_IP);
        let retUrl = '/Modules/GeneralList/GeneralList.htm?request=EgovPlatform_TaskOfCirculated_List&request_type=13&idKey='+record.KEY1+'#';
        let ReturnUrl = encodeURIComponent(retUrl)
        let url = baseUrl + "/login.xip?LoginMethod=ssologin&Ticket=" + ticket + UserIP + "&ReturnUrl="+ ReturnUrl
        openIFrame(record.报建编号, '/General/' + record.报建编号, record.报建编号, url)
        this.$router.push({ name: record.报建编号 })
      },
      getGeneralList() {
        let that = this
        let params = {
          serviceName: 'Xinfo.Bus.BL.Service.EgovPlatform.PortalLet.TaskOfCirculatedPortalLetService,Xinfo.Bus.BL.Service',
          guid: 'rcgz_dyrw',
          getCount: true,
          intTypeId: 0,
          strBizType: ''
        }
        this.getRequest('/PortalLet/GetPortalLetData', params)
          .then(res => {
            that.read = [];
            res.data.forEach((row, index) => {
              if (index < 10) {
                that.read.push(row)
              }
            })
            that.count = res.count
            that.sendCountToParent()
          })
      }
    }
  }
</script>
<style>
  .a {
    margin-top: 0;
    color: #40a9ff;
    font-size: 18px;
    font-weight: 500;
    float: right;
    margin-right: 30px;
  }
  #readingformdiv .el-table td, .el-table th {
    padding: 10px 0!important;
  }
</style>
<style scoped>
</style>